-
Notifications
You must be signed in to change notification settings - Fork 21
tests: unittest: adding unit tests for ble_gq lib #314
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
You can find the documentation preview for this PR here. |
tests/lib/ble_gq/src/unity_test.c
Outdated
uint16_t conn_handle = 0x0C4; | ||
|
||
ble_evt.header.evt_id = BLE_GAP_EVT_DISCONNECTED; | ||
ble_evt.evt.gap_evt.conn_handle = 0x0C4; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: I would consider defining 0x0C4
somewhere and then reusing the definition in all the different occurrences, rather than hardcoding the value.
No milestone required for tests |
tests/lib/ble_gq/src/unity_test.c
Outdated
for (int i = 0; i < ble_gq.max_conns; i++) { | ||
ble_gq.conn_handles[i] = i + 1; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should not alter the ble_gq ourselves. Perhaps register up to max_conns
handlers successfully, then see that the next fails?
tests/lib/ble_gq/src/unity_test.c
Outdated
sys_slist_init(&ble_gq.req_queue[0]); | ||
sys_slist_append(&ble_gq.req_queue[0], &req.node); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There should be another way to append these than by altering the struct with slist. Use ble_gq_item_add()
?
54395ef
to
651a388
Compare
Added unit tests for ble_gq library Signed-off-by: Nirmal Krishna <[email protected]> Co-authored-by: Andreas Moltumyr <[email protected]>
651a388
to
30b2973
Compare
TEST_ASSERT_EQUAL(NRF_ERROR_INVALID_STATE, glob_error); | ||
} | ||
|
||
void test_ble_gq_item_add_req_gatt_write(void) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
void test_ble_gq_item_add_req_gatt_write(void) | |
void test_ble_gq_item_add_req_gattc_write_error_resources(void) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there are more cases like this. When not having a error at the end, we expect it to test a successful case. In this (and the other) case it is not, as the handler is called with an error.
TEST_ASSERT_EQUAL(NRF_ERROR_RESOURCES, glob_error); | ||
} | ||
|
||
void test_ble_gq_item_add_req_srv_discovery(void) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
void test_ble_gq_item_add_req_srv_discovery(void) | |
void test_ble_gq_item_add_req_srv_discovery_timeout(void) |
ble_gq.conn_handles[0] = 0; | ||
|
||
__cmock_sd_ble_gattc_write_ExpectAndReturn(conn_handle, &req.gattc_write, NRF_ERROR_BUSY); | ||
__cmock_sd_ble_gattc_write_IgnoreAndReturn(NRF_ERROR_RESOURCES); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see any test where the second call returns success, and we check glob_error for NRF_SUCCESS.
Added unit tests for ble_gq library